﻿using FlowCanvas.Nodes;
using Yoozoo.Gameplay.Liberty.AI;

namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    public class SwitchInvincibleState : CallableActionNode<int, bool>
    {
        public override void Invoke(int streetNpcId, bool invincible)
        {
            int uniqueId = -999;
            if (streetNpcId == -1)
            {
                uniqueId = -1;
            }
            else
            {
                var md = StreetEventManager.GetInstance("").GetMonster(streetNpcId);
                if (md != null)
                {
                    uniqueId = md.uniqueId;
                }
            }
            
            var aiEntity = LibertyAIUtils.GetNpc(uniqueId);
            if (aiEntity != null)
            {
                aiEntity.data.invincible = invincible;
            }
        }
    }
}